package hander

import (
	"chat/api/request"
	"chat/internal/dao"
	"chat/internal/model"
	"github.com/gin-gonic/gin"
	"net/http"
)

func List(c *gin.Context) {
	var video []model.Videos
	dao.Find(&video)
	c.JSON(http.StatusOK, gin.H{
		"msg":  "OK",
		"code": 200,
		"data": video,
	})
}

func Select(c *gin.Context) {
	var req request.SelectReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusOK, gin.H{
			"msg":  "验证失败",
			"code": 500,
			"data": err.Error(),
		})
		return
	}
	var video model.Videos
	dao.Find1(req.Message, &video)
	if video.Id == 0 {
		c.JSON(http.StatusOK, gin.H{
			"msg":  "视频不存在",
			"code": 500,
			"data": nil,
		})
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"msg":  "OK",
		"code": 200,
		"data": video,
	})
}
